package com.ys.controller.api;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ys.entity.business.TpQuestion;
import com.ys.service.business.TpQuestionService;
import com.ys.service.sys.CommonApiService;
import com.ys.vo.LayuiTableVoJA;

@Controller
@RequestMapping("/api/inter/tpQuestion")
public class ApiInterTpQuestionController {
	
//	private static final Logger logger = Logger.getLogger(ApiAdminLoginController.class);
	
	@Autowired
	private CommonApiService<TpQuestion> commonApiService;
	@Autowired
	private TpQuestionService tpQuestionService;

//	@RequiresPermissions("tpFbaPlanOrder:view")
	@RequestMapping("/search")
    @ResponseBody
	public LayuiTableVoJA search(Model model, HttpServletRequest request, HttpServletResponse response,
			@ModelAttribute TpQuestion cond,
			String conditions
			){
		return commonApiService.searchLay(cond);
	}
	/**
	 * 新增
	 */
	
	@PostMapping("/add")
    @ResponseBody
	public com.ys.vo.R add(HttpServletRequest request, @RequestParam Map<String, Object> params,
			@ModelAttribute TpQuestion cond,
			String conditions
			){
		cond.setFields("A.UserName userName,A.DeptName deptName,A.CreateCodeCompany createCodeCompany,A.CreateUserId createUserId,A.VGsJc vGsJc,A.Nameyyr nameyyr,"
			+"A.Deptyyr deptyyr,A.VGsBmsj vGsBmsj,A.VGsJcsj vGsJcsj,A.Namesj namesj,A.Codesj codesj,A.Deptsj deptsj,"	
			+ "B.ShopName shopName,B.Vgsbm vgsbm,C.CUser userId,C.VGsJc vGsJc,C.CUserName userName,"
			+ "C.UserLeader userLeader");
	
		cond.addLeftJoin("THR_OperateCompanyApply B on B.BUser = A.CreateUserId");
		cond.addLeftJoin("TS_UserInfo C on C.UserId = B.CUser");
		cond.addLeftJoin("TS_RoleInfo D on D.Guid = C.PositionGuid");
		return tpQuestionService.add(params);
	}
//	/**
//	 * 修改
//	 */
//	@PostMapping("/edit")
//    @ResponseBody
//	public R edit(HttpServletRequest request, @RequestParam Map<String, Object> params){
//		return tpQuestionService.edit(params);
//	}
//	/**
//	 * 导出
//	 */
//	@PostMapping("/export")
//    @ResponseBody
//	public R export(HttpServletRequest request, @RequestParam Map<String, Object> params){
//		return tpQuestionService.export(params);
//	}
} 